package com.itheima.jdk8date;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Demo2 {
    public static void main(String[] args) {
        method1();
        method2();
    }

    private static void method2() {
        String s = "2020年09月23日 15:58:01";
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
        LocalDateTime parse = LocalDateTime.parse(s, pattern);
        System.out.println(parse);
    }


    private static void method1() {
        LocalDateTime localDateTime = LocalDateTime.of(2020, 9, 23, 15, 58, 01);
        System.out.println(localDateTime);
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
        String s = localDateTime.format(pattern);
        System.out.println(s);
    }
}
